﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKRevitKernel.FormUtility;
using YJKCopyModel.GeothermalPipeQuickModel;

namespace YJKCopyModel.Forms.GeothermalPipe
{
	public partial class GeothermalPipeSelectForm : System.Windows.Forms.Form
	{
		public CloseGeothermalDlgType DlgCloseType
		{
			get
			{
				return this.m_DlgCloseType;
			}
		}

		public GeothermalPipeSelectForm()
		{
			this.InitializeComponent();
			this.m_DlgCloseType = CloseGeothermalDlgType.Other;
			this.AddControlGroup();
			this.m_ControlInfoManager = new ControlInfoManager(this, this.m_lstControlGroup, null, null);
			this.btnOK.Enabled = false;
		}

		public bool SetBtnOkEnableControl
		{
			set
			{
				this.btnOK.Enabled = true;
			}
		}

		public bool GetRadSameState
		{
			get
			{
				return this.radSame.Checked;
			}
		}

		private void radSame_Click(object sender, EventArgs e)
		{
			bool @checked = this.radSame.Checked;
			if (@checked)
			{
				this.btnWaterSupply.Text = "请选择地盘图层";
				this.radDif.Checked = false;
				this.btnWaterBack.Enabled = false;
			}
			else
			{
				this.btnWaterSupply.Text = "请选择供水图层";
				this.radDif.Checked = true;
				this.btnWaterBack.Enabled = true;
			}
            //this.pbxSupply.BackgroundImage = Resources.QuickModelGray;
            //this.pbxBack.BackgroundImage = Resources.QuickModelGray;
			this.m_DlgCloseType = CloseGeothermalDlgType.SelectSupplyLine;
		}

		private void btnWaterSupply_Click(object sender, EventArgs e)
		{
			this.m_DlgCloseType = CloseGeothermalDlgType.SelectSupplyLine;
			bool @checked = this.radDif.Checked;
			if (@checked)
			{
				GeothermalFormData.IsSame = false;
				GeothermalFormData.IsDiff = true;
			}
			else
			{
				GeothermalFormData.IsSame = true;
				GeothermalFormData.IsDiff = false;
			}
			base.DialogResult = DialogResult.OK;
		}

		private void btnWaterBack_Click(object sender, EventArgs e)
		{
			this.m_DlgCloseType = CloseGeothermalDlgType.SelectBackLine;
			base.DialogResult = DialogResult.OK;
		}

		private void radDif_Click(object sender, EventArgs e)
		{
			bool @checked = this.radDif.Checked;
			if (@checked)
			{
				this.btnWaterSupply.Text = "请选择供水图层";
				this.radSame.Checked = false;
				this.btnWaterBack.Enabled = true;
				GeothermalFormData.IsDiff = true;
			}
			else
			{
				this.btnWaterSupply.Text = "请选择地盘图层";
				this.radSame.Checked = true;
				this.btnWaterBack.Enabled = false;
			}
            //this.pbxSupply.BackgroundImage = Resources.QuickModelGray;
            //this.pbxBack.BackgroundImage = Resources.QuickModelGray;
			this.m_DlgCloseType = CloseGeothermalDlgType.SelectSupplyLine;
		}

		private void GeothermalPipeSelectForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			bool @checked = this.radSame.Checked;
			if (@checked)
			{
				this.btnWaterSupply.Text = "请选择地盘图层";
				this.radDif.Checked = false;
				this.btnWaterBack.Enabled = false;
			}
			else
			{
				this.btnWaterSupply.Text = "请选择供水图层";
				this.radDif.Checked = true;
				this.btnWaterBack.Enabled = true;
			}
			this.m_ControlInfoManager.SetControlInfoToForm();
		}

		private void AddControlGroup()
		{
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.radSame, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.radDif, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxSupply, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxBack, false));
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			bool @checked = this.radDif.Checked;
			if (@checked)
			{
				GeothermalFormData.IsSame = false;
				GeothermalFormData.IsDiff = true;
			}
			else
			{
				GeothermalFormData.IsSame = true;
				GeothermalFormData.IsDiff = false;
			}
			this.m_DlgCloseType = CloseGeothermalDlgType.NextButton;
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void GeothermalPipeSelectForm_KeyDown(object sender, KeyEventArgs e)
		{
			bool flag = e.KeyValue == 27;
			if (flag)
			{
				base.DialogResult = DialogResult.Cancel;
			}
		}

		private void hyGroupBoxBlackSide1_FontChanged(object sender, EventArgs e)
		{
			bool flag = this.m_ControlInfoManager != null;
			if (flag)
			{
				this.m_ControlInfoManager.GetControlInfoToXml();
			}
		}

		private void GeothermalPipeSelectForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			bool flag = this.m_ControlInfoManager != null;
			if (flag)
			{
				this.m_ControlInfoManager.GetControlInfoToXml();
			}
		}

		private ControlInfoManager m_ControlInfoManager = null;

		private List<KeyValuePair<System.Windows.Forms.Control, bool>> m_lstControlGroup = new List<KeyValuePair<System.Windows.Forms.Control, bool>>();

		private CloseGeothermalDlgType m_DlgCloseType;
	}
}
